package cloud.xlh.my_system.controller;

import cloud.xlh.my_system.common.response.Response;
import cloud.xlh.my_system.pojo.GenTable;
import cloud.xlh.my_system.service.GenTableService;
import cloud.xlh.my_system.service.GenerateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : code-generator
 * @ Author: XuLeHuang
 * @ Date: 2022/6/20 12:39
 * @ Description:
 */
@Controller
@RequestMapping("/generate")
public class GenerateController {
    @Autowired
    private GenerateService generateService;


    @RequestMapping("/toListPage")
    public String toListPage() {
        return "/generate-manage/list";
    }

    /**
     * 生成代码
     *
     * @param tableName 表格名称
     */
    @PostMapping("/{tableName}/{projectId}")
    @ResponseBody
    public Response<String> genCode(@PathVariable("tableName") String tableName , @PathVariable("projectId")String projectId , GenTable genTable) {
        return generateService.generatorCode(tableName , projectId);
    }
}
